home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
4thcmp21.zip
/
EXEC.4TH
< prev
next >
Wrap
Text File
|
1993-06-23
|
2KB
|
74 lines
\ DOS EXECUTE LIBRARY
\ Contents Copyright (C) 1991 by Thomas Almy
\ Revised 3/93 by Tom Almy
\ Permission is granted to registered users of ForthCMP to sell or distribute
\ computer programs incorporating the compiled contents of this file.
\ This file should be loaded at the start of the program. The
\ STRINGS library must be loaded, and loaded before this file.
.( Loading EXEC) CR
10 HEX
DSEG
CREATE xpb 0E ALLOT
0 xpb ! -1 xpb 6 + ! -1 xpb 8 + ! -1 xpb 0A + ! -1 xpb 0C + !
CSEG
CREATE ssav 0 , 0 ,
DSEG
\ the code for exec could be optimized based on SEPSSEG? and SEPDSEG?
\ either or both being off, but it would not make that much difference
\ in code size.
\ code 9C is PUSHF, 9D is POPF
1 1 IN/OUT
CODE exec ( ^ASCIIZCommand -- failFlag )
BP PUSH CSEG 9C C, DS PUSHSEG
AX DX MOV
CS: ssav 2+ [] SS <SEG SP CS: ssav [] MOV
AX DS <SEG AX ES >SEG
4B00 # AX MOV
xpb # BX MOV
21 INT
CS: ssav 2+ [] SS >SEG
CS: ssav [] SP MOV
DS POPSEG 9D C, BP POP
<U ~ IF, AX AX XOR THEN, RET
END-CODE
DSEG
CREATE crChr 3 ALLOT
0D crChr C! \ crChr 1 is string consisting of CR only
20 crChr 1+ C! \ while crChr 1+ 1 is string consisting of BL only
0 crChr 2+ C! \ and crChr 2+ is counted zero length string
2 1 IN/OUT
: spawn ( ^command ^args -- failFlag )
crChr 1+ 1 ROT COUNT STRCAT
crChr 1 STRCAT STRPCK -1 OVER +!
xpb 2+ ! ?DS: xpb 4 + !
ASCIIZ exec
;
1 0 IN/OUT
SEPDSEG? #IF
: EXEC
" COMSPEC" STR>DSEG getenv ?DUP IF
SWAP DUP C@ IF \ program to run
" /C " STR>DSEG COUNT ROT COUNT STRCAT STRPCK
ELSE DROP crChr 2+ THEN
spawn DROP
ELSE ." No COMSPEC" BYE THEN ;
#ELSE
: EXEC
" COMSPEC" getenv ?DUP IF
SWAP DUP C@ IF \ program to run
CNT" /C " ROT COUNT STRCAT STRPCK
ELSE DROP crChr 2+ THEN
spawn DROP
ELSE ." No COMSPEC" BYE THEN ;
#THEN
0A = #IF DECIMAL #THEN